package cn.wolfcode.crm.domain;

import com.alibaba.fastjson.JSON;
import lombok.Getter;
import lombok.Setter;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

@Setter
@Getter
public class CourseOrder {
    private Long id;

    private Date inputTime;

    //潜在客户
    private Customer customer;
    //购买课程 在字典明细中
    private SystemDictionaryItem course;

    private Long money;

    public String getJson() {
        Map<String, Object> map = new HashMap<>();
        map.put("id", this.id);
        map.put("inputTime", this.inputTime);
        map.put("money", this.money);

        if (this.customer != null) {
            map.put("customerId", this.customer.getId());
            map.put("customerName", this.customer.getName());
        }
        if (this.course != null) {
            map.put("courseId", this.course.getId());
            map.put("courseTitle", this.course.getTitle());
        }
        return JSON.toJSONString(map);
    }
}